const express = require('express')

const app = express()


//中间件
let mw1 = (req, res, next) => {
    console.log("I'm middleware1")
    next()
}

let mw2 = (req, res, next) => {
    console.log("I'm middleware2")
    next()
}

// app.use(mw)

app.get('/', mw1, (req, res) => {
    res.send({
        msg: '好好学习 天天向上 中间件get'
    })
})

app.post('/', [mw1, mw2], (req, res) => {
    res.send({
        msg: '好好学习 天天向上 中间件post'
    })
})

app.listen(3000, () => {
    console.log('3000 running')
})